﻿@model Htinns.GatewayConsole.Models.Vote
@{
	ViewBag.Title = "客房网络服务使用情况调查问卷";
}
<script src="@Url.Content("~/Scripts/Calendar/WdatePicker.js")" type="text/javascript"  ></script>	
<div class="container" id="q-result">
<div class="result">
	<h2>调查题目：“@Model.Title”</h2>	
	<div>
		<ul class="voteList">
		@foreach(var item in Model.VoteItems){			
			<li>
				<label>@item.Id @item.Content</label>
				<p><span class="progress"><abbr class="@Html.Raw("i"+item.Id)" style="width:@item.Percent%"></abbr></span><span class="tickets"> ： @item.VoteSheets.Count(h => h.HotelId == ViewBag.HotelId) 票 (@item.Percent%)</span></p>
			</li>
		}
		</ul>
		<h3 style="margin-top:20px;">
			本调查已经有 <span class="dred">@ViewBag.VoteSheetCount</span>人参与调查。
		</h3>
	</div>			
	<p class="backCon">@Html.ActionLink("返回投票", "Questionnaire", "Home", new { id = ViewBag.HotelId }, new { @class = "lnkred" })</p>	
</div>
<div class="msg">
	<div class="datePicker">
		<label for="date">★ 客人建议与反馈，在</label>
		<input type="text" id="beginDate" name="beginDate" class="Wdate" value="@DateTime.Today.AddDays(-2)" /> 至 
		<input type="text" id="endDate" name="endDate"  class="Wdate" value="@DateTime.Now"  /> 期间：
	</div>
	<ul id="msgList">
	@foreach (var sheet in (IEnumerable<Htinns.GatewayConsole.Models.VoteSheet>)ViewBag.VoteMsg)
	{
		<li id="@string.Format("s{0}",sheet.Id)">
			<p> <span class="gray">@sheet.Operator </span>： <span class="backgray">@sheet.Description </span> </p>
			<p class="gray txtRight">@sheet.CreatedDate, 房间 @sheet.RoomNo 的客人</p>
		</li>
	}
	</ul>
	<p class="txtCenter" style="display:none"><a href="#" id="viewMore">查看更多……</a></p>
</div>
</div>

<script type="text/javascript">
<!--

	$(function () {
		initDate();	
		
	});
	function initDate() {
		$("#beginDate").focus(function () {
			WdatePicker({
				doubleCalendar: true,
				isShowOthers: false,
				isShowToday: false,
				isShowClear: false,
				isShowOK: false,
				qsEnabled: false,
				dateFmt: 'yyyy-MM-dd HH:00',
				onpicked:getNewMsg	
			});
			
		});
		$("#endDate").focus(function () {
			WdatePicker({
				doubleCalendar: true,
				isShowOthers: false,
				isShowToday: false,
				isShowClear: false,
				isShowOK: false,
				qsEnabled: false,
				dateFmt:'yyyy-MM-dd HH:00',
				minDate: '#F{$dp.$D(\'beginDate\')}',
				onpicked:getNewMsg	
			});
		});
	}

	function getNewMsg(dp) {
		var bDateStr=$("#beginDate").val();
		var eDateStr=$("#endDate").val();
		var beginDate = new Date(bDateStr);
		var endDate = new Date(eDateStr);
		if (beginDate > endDate) {
			alert("无法查询，请修正日期区间"); return;
		}				
		var html = '<li id="s#0"><p> <span class="gray">#1</span>： <span class="backgray">#2 </span> </p>'
				+ '<p class="gray txtRight">#3, 房间 #4 的客人</p></li>';

		var url = '@Url.Action("GetVoteSheetMsg","Home",new{id=ViewBag.HotelId})' + "?beginDate=" + bDateStr + "&endDate=" + eDateStr;

		$.get(url, function (msgList) {
			if (!msgList) return;
			msgList = eval('(' + msgList + ')');
			var allMsg = "";
			for (var i in msgList) {
				var msg = html.replace(/#0/, msgList[i].i)
						.replace(/#1/, msgList[i].n)
						.replace(/#2/, msgList[i].d)
						.replace(/#3/, msgList[i].t)
						.replace(/#4/, msgList[i].r);
				allMsg += msg;
			}
			$("#msgList").html(allMsg);
		});
		
	}
	
//-->
</script>

